#include "EEExpMath.h"
#include <math.h>

//*********************************************
//Vector3
//*********************************************
vector3 vector3::operator + (const vector3& v) const
{
	return vector3(v.x + x,v.y + y,v.z + z);
}
	
vector3 vector3::operator - (const vector3& v) const
{
	return vector3(x - v.x,y - v.y,z - v.z);
}

vector3 vector3::operator * (const float v) const
{
	return vector3(v * x,v * y,v * z);
}

vector3 vector3::operator / (const float v) const
{
	return (v == 0.0f) ? vector3() : vector3(x / v,y / v,z / v);
}

vector3 vector3::operator = (const vector3& v)
{
	x = v.x;
	y = v.y;
	z = v.z;
	return *this;
}

float vector3::dot(vector3& a, vector3& b)
{
	return (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
}

void vector3::normalize(vector3& a)
{
	float l = sqrt((a.x * a.x) + (a.y * a.y) + (a.z * a.z));
	a = a * (1.0f / l);
}

float vector3::length(vector3& a)
{
	return sqrt((a.x * a.x) + (a.y * a.y) + (a.z * a.z));
}

vector3 vector3::baseLerp(float t, vector3& A, vector3& B)
{
	return A + ((B - A) * t);
}

//*********************************************
//Vector2
//*********************************************
vector2 vector2::operator + (const vector2& v) const
{
	return vector2(v.x + x,v.y + y);
}
	
vector2 vector2::operator - (const vector2& v) const
{
	return vector2(x - v.x,y - v.y);
}

vector2 vector2::operator * (const float v) const
{
	return vector2(v * x,v * y);
}

vector2 vector2::operator / (const float v) const
{
	return (v == 0.0f) ? vector2() : vector2(x / v,y / v);
}

vector2 vector2::operator = (const vector2& v)
{
	x = v.x;
	y = v.y;
	return *this;
}

vector2 vector2::baseLerp(float t, vector2& A, vector2& B)
{
	return A + ((B - A) * t);
}